package blackitheima1.ObjectTest.test4;

import java.util.Objects;

public class ObjectsTest {
    public static void main(String[] args) {
        Student s=new Student("鲁智深",24);
        String s1 = Objects.toString(s);
        System.out.println(s);
        System.out.println(s1);

        //Objects 对象为null时,执行第二个参数
        Student s2=null;
        String s3 = Objects.toString(s2, "洒家乃是null!");
        System.out.println(s3);

        //判断对象是否为null           isNull
        boolean aNull = Objects.isNull(s2);//true
        System.out.println(aNull);

        //判断对象是否不为null      nonNull
        boolean b = Objects.nonNull(s2);//false
        System.out.println(b);

    }
}
